package com.unionpay.service.common.excel;

import java.util.Objects;

/**
 * @ClassName ExcelField
 * @Description: excel映射字段
 * @Author xsl
 * @Date 2021/1/14
 */
public class ExcelField {
    private String fieldName;
    private FieldHandle handle;
    private int index;

    public String getFieldName() {
        return fieldName;
    }

    public FieldHandle getHandle() {
        return handle;
    }

    public int getIndex() {
        return index;
    }

    private ExcelField(){
    }

    public static ExcelField build(String fieldName, int index ,FieldHandle handle){
        ExcelField excelField = build(fieldName, index);
        excelField.handle = handle;
        return excelField;
    }


    public static ExcelField build(String fieldName, int index){
        ExcelField excelField = new ExcelField();
        excelField.fieldName = fieldName;
        excelField.index = index;
        return excelField;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (Objects.isNull(o) || getClass() != o.getClass()) return false;
        ExcelField that = (ExcelField) o;
        return index == that.index &&
                Objects.equals(fieldName, that.fieldName) &&
                Objects.equals(handle, that.handle);
    }

    @Override
    public int hashCode() {
        return Objects.hash(fieldName, handle, index);
    }
}